//  开启数据库
const mongoose = require('mongoose');
const MongoApp = mongoose.createConnection('mongodb://127.0.0.1:27017/jinXiaoCun', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  useFindAndModify: false
});

const Schema = mongoose.Schema;
//监听数据库的状态
MongoApp.on('open', () => {
  console.log('数据库连接成功');
});
MongoApp.on('error', () => {
  console.log('数据库连接错误');
});
module.exports = { MongoApp, Schema };
